package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.vo.CheckGroupVO;
import com.itheima.health.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetMealMapper extends BaseMapper<Setmeal> {
    @Insert("insert into t_setmeal_checkgroup values(#{id},#{checkgroupId})")
    void addSetmealAndGroupInfo(@Param("id") Integer id, @Param("checkgroupId") Integer checkgroupId);

    @Select("SELECT NAME,age,remark,sex,img " +
            "FROM t_setmeal " +
            "WHERE id=#{id}")
    SetmealVO findSetmealById(@Param("id") int id);

    @Select("SELECT tc.ID,tc.NAME,tc.REMARK " +
            "FROM t_checkgroup tc,t_setmeal_checkgroup tsc " +
            "WHERE tc.ID = tsc.CHECKGROUP_ID " +
            "AND tsc.setmeal_id= #{id}")
    List<CheckGroupVO> findCheckgroupBySetmealId(@Param("id") int id);

    @Select("SELECT tc.NAME " +
            "FROM t_checkgroup_checkitem tcc,t_checkitem tc " +
            "WHERE tcc.CHECKITEM_ID = tc.ID " +
            "AND tcc.CHECKGROUP_ID = #{id}")
    List<CheckItem> findCheckitemByCheckgroupId(@Param("id") Integer id);


}
